<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@include file="/includes.jsp"%>

<table class="layout">
    <tr>
        <th class="layout">Node:</th>
        <td class="layout"><beans:write name="nodeValue" property="name"/></td>
    </tr>
    <tr>
        <th class="layout">Date:</th>
        <td class="layout">
            <html:form action="activitytime.do?method=showTime" method="post">
                <html:hidden name="taskTimeAF" property="nodeId"/>
                <html:select name="taskTimeAF" property="year" size="1">
                    <html:options collection="years" property="integer" labelProperty="string"/>
                </html:select>-<html:select name="taskTimeAF" property="month" size="1">
                    <html:options collection="months" property="integer" labelProperty="string"/>
                </html:select>-<html:select name="taskTimeAF" property="day" size="1">
                    <html:options collection="days" property="integer" labelProperty="string"/>
                </html:select>
                <html:submit property="btnSubmit" value="<"/>
                <html:submit property="btnSubmit" value="Go"/>
                <html:submit property="btnSubmit" value=">"/>
            </html:form>
        </td>
    </tr>
    <tr>
        <th class="layout">Duration:</th>
        <beans:define id="duration" name="taskDuration"/>
        <jsp:useBean id="durationHours" class="java.util.Date"/>
        <jsp:useBean id="durationMins" class="java.util.Date"/>
        <jsp:setProperty name="durationHours" property="time" value="<%=((Long)duration).longValue()/3600000L%>"/>
        <jsp:setProperty name="durationMins" property="time" value="<%=(((Long)duration).longValue()/60000L)%60L%>"/>
        <td class="layout"><beans:write name="durationHours" property="time" format="##"/>h:<beans:write name="durationMins" property="time" format="00"/>m</td>
    </tr>
</table>
<table class="styled" cellspacing="0">
    <tr>
        <th class="styled">Person</th>
        <th class="styled">Description</th>
        <th class="styled">State</th>
        <th class="styled">Start</th>
        <th class="styled">Stop</th>
        <th class="styled">Duration</th>
        <th class="styled">Remaining</th>
        <th class="styled">Edit?</th>
        <th class="styled">Delete?</th>
    </tr>
    <logic:iterate name="taskTimeValue" id="time">
        <tr>
            <td class="styled"><beans:write name="time" property="personName"/></td>
            <td class="styled"><velocityme:markup><beans:write name="time" property="description"/></velocityme:markup></td>
            <td class="styled"><beans:write name="time" property="stateName"/></td>
            <td class="styled"><beans:write name="time" property="start" format="yyyy-MM-dd HH:mm:ss"/></td>
            <td class="styled"><beans:write name="time" property="stop" format="HH:mm:ss"/></td>
            <jsp:setProperty name="durationHours" property="time" value="<%=((TimeDTO)time).getDuration()/3600000L%>"/>
            <jsp:setProperty name="durationMins" property="time" value="<%=(((TimeDTO)time).getDuration()/60000L)%60L%>"/>
            <td class="styled"><beans:write name="durationHours" property="time" format="##"/>h:<beans:write name="durationMins" property="time" format="00"/>m</td>
            <td class="styled"><beans:write name="time" property="remainingDuration_format"/></td>
            <html:form action="timeEdit.do?method=showTimeEdit" method="post">
                <html:hidden name="time" property="timeId"/>
                <td class="styled" style="text-align: center;">
                    <logic:equal name="time" property="isEditable" value="true">
                        <html:submit property="btnEdit" value="Edit"/>
                    </logic:equal>
                    <logic:notEqual name="time" property="isEditable" value="true">
                        No permission
                    </logic:notEqual>
                </td>
            </html:form>
            <html:form action="timeEdit.do?method=timeDeleteCheck" method="post">
                <html:hidden name="time" property="timeId"/>
                <td class="styled" style="text-align: center;">
                    <logic:equal name="time" property="isDeletable" value="true">
                        <html:submit property="btnDelete" value="Delete"/>
                    </logic:equal>
                    <logic:notEqual name="time" property="isDeletable" value="true">
                        No permission
                    </logic:notEqual>
                </td>
            </html:form>
        </tr>
    </logic:iterate>
</table>
